#!/usr/bin/node

const cp = require('child_process');

console.log('12-pid is ', process.pid);

//var child = cp.fork('./11-ipc-child.js');

let son = cp.fork('./11-ipc-child.js');
let girl = cp.fork('./11-ipc-child.js');

son.on('message', (data) => {
  console.log('i have a son:', data);

});

girl.on('message', (data) => {
  console.log('i have a girl', data);
});


setTimeout(() => {
  son.send('goog goog stydy');

}, 2000);

setTimeout(() => {
  girl.send('day day up');

}, 3000);

setTimeout(() => {
  son.kill('SIGINT');
  girl.kill('SIGINT');
  process.exit();

}, 6000);

